package com.zk.spring5;

import com.zk.spring5.aop_annotation.User;
import com.zk.spring5.aop_xml.Book;
import com.zk.spring5.config.AopConfig;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author ZK
 * @Description
 * @time 2021/5/5 15:40
 * @note
 */
public class SpringTest {
    @Test
    public void testAopAnnotation(){
        User user = new ClassPathXmlApplicationContext("bean1.xml").getBean("user", User.class);
        user.add();
    }

    @Test
    public void testAopAnnotation2(){
        User user = new ClassPathXmlApplicationContext("bean1.xml").getBean("user", User.class);
        user.setBook(new com.zk.spring5.aop_annotation.Book("java","zk"));
        System.out.println(user.getBook());
    }

    @Test
    public void testAopXML(){
        Book book = new ClassPathXmlApplicationContext("AopXML.xml").getBean("book", Book.class);
        book.show();
    }
    @Test
    public void testAopConfig(){
        User user = new AnnotationConfigApplicationContext(AopConfig.class).getBean("user", User.class);
        user.add();
    }
}
